<!DOCTYPE html>

<html>
<head>
  <title>#</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
  <div id="container">
    <div id="background"></div>
    
      <ul id="jump_to">
        <li>
          <a class="large" href="javascript:void(0);">Jump To &hellip;</a>
          <a class="small" href="javascript:void(0);">+</a>
          <div id="jump_wrapper">
          <div id="jump_page">
            
              
              <a class="source" href="Array.coffee.html">
                Array.coffee.md
              </a>
            
              
              <a class="source" href="BareObject.coffee.html">
                BareObject.coffee.md
              </a>
            
              
              <a class="source" href="Boolean.coffee.html">
                Boolean.coffee.md
              </a>
            
              
              <a class="source" href="Function.coffee.html">
                Function.coffee.md
              </a>
            
              
              <a class="source" href="Math.coffee.html">
                Math.coffee.md
              </a>
            
              
              <a class="source" href="Maybe.coffee.html">
                Maybe.coffee.md
              </a>
            
              
              <a class="source" href="Nullable.coffee.html">
                Nullable.coffee.md
              </a>
            
              
              <a class="source" href="Number.coffee.html">
                Number.coffee.md
              </a>
            
              
              <a class="source" href="Object.coffee.html">
                Object.coffee.md
              </a>
            
              
              <a class="source" href="Promise.coffee.html">
                Promise.coffee.md
              </a>
            
              
              <a class="source" href="String.coffee.html">
                String.coffee.md
              </a>
            
              
              <a class="source" href="Type.coffee.html">
                Type.coffee.md
              </a>
            
              
              <a class="source" href="header.coffee.html">
                header.coffee.md
              </a>
            
          </div>
        </li>
      </ul>
    
    <ul class="sections">
        
        
        
        <li id="section-1">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-1">&#182;</a>
              </div>
              <h1 id="-">#</h1>

            </div>
            
            <div class="content"><div class='highlight'><pre>	Opal JavaScript Library
	<span class="hljs-attribute">http</span>:<span class="hljs-regexp">//</span>code.google.com<span class="hljs-regexp">/p/jmodel/</span>

	Copyright (c) <span class="hljs-number">2009</span>-<span class="hljs-number">2013</span> Richard Baker
	Dual licensed under the MIT <span class="hljs-keyword">and</span> GPL licenses</pre></div></div>
            
        </li>
        
        
        <li id="section-2">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-2">&#182;</a>
              </div>
              <h1 id="-">#</h1>

            </div>
            
            <div class="content"><div class='highlight'><pre>
define<span class="hljs-function"> -&gt;</span></pre></div></div>
            
        </li>
        
        
        <li id="section-3">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-3">&#182;</a>
              </div>
              <p>NOTE: Define assert here</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>
	<span class="hljs-built_in">window</span>.<span class="hljs-function"><span class="hljs-title">Value</span> = -&gt;</span>
	<span class="hljs-built_in">window</span>.Value.<span class="hljs-function"><span class="hljs-title">equal</span> = <span class="hljs-params">(x,y)</span> -&gt;</span>
		<span class="hljs-keyword">switch</span>
			<span class="hljs-keyword">when</span> x <span class="hljs-keyword">instanceof</span> Boolean <span class="hljs-keyword">and</span> y <span class="hljs-keyword">instanceof</span> Boolean <span class="hljs-keyword">then</span> x == y
			<span class="hljs-keyword">when</span> x <span class="hljs-keyword">instanceof</span> Number <span class="hljs-keyword">and</span> y <span class="hljs-keyword">instanceof</span> Number <span class="hljs-keyword">then</span> +x == +y
			<span class="hljs-keyword">when</span> x.constructor == Object <span class="hljs-keyword">then</span> Object.equal(x,y)
			<span class="hljs-keyword">else</span> x == y
	<span class="hljs-built_in">window</span>.Value.<span class="hljs-function"><span class="hljs-title">lt</span> = <span class="hljs-params">(x,y)</span> -&gt;</span> x &lt; y
	<span class="hljs-built_in">window</span>.Value.<span class="hljs-function"><span class="hljs-title">valid</span> = <span class="hljs-params">(x)</span> -&gt;</span> x != <span class="hljs-literal">undefined</span>
	
	<span class="hljs-built_in">window</span>.<span class="hljs-function"><span class="hljs-title">Scalar</span> = -&gt;</span>
	<span class="hljs-built_in">window</span>.Scalar.<span class="hljs-function"><span class="hljs-title">valid</span> = <span class="hljs-params">(x)</span> -&gt;</span>
		<span class="hljs-keyword">typeof</span> x == <span class="hljs-string">'number'</span> \
		<span class="hljs-keyword">or</span> <span class="hljs-keyword">typeof</span> x == <span class="hljs-string">'string'</span> \
		<span class="hljs-keyword">or</span> <span class="hljs-keyword">typeof</span> x == <span class="hljs-string">'boolean'</span> \
		<span class="hljs-keyword">or</span> x == <span class="hljs-literal">null</span> \
		<span class="hljs-keyword">or</span> x <span class="hljs-keyword">instanceof</span> Number \
		<span class="hljs-keyword">or</span> x <span class="hljs-keyword">instanceof</span> String \
		<span class="hljs-keyword">or</span> x <span class="hljs-keyword">instanceof</span> Boolean
	
	<span class="hljs-built_in">window</span>.<span class="hljs-function"><span class="hljs-title">Not</span> = <span class="hljs-params">(constructor)</span> -&gt;</span>
		<span class="hljs-function"><span class="hljs-title">fn</span> = -&gt;</span>
		valid = Object.isa constructor
		fn.<span class="hljs-function"><span class="hljs-title">valid</span> = <span class="hljs-params">(x)</span> -&gt;</span> x? <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> valid x
		<span class="hljs-keyword">return</span> fn</pre></div></div>
            
        </li>
        
        
        <li id="section-4">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-4">&#182;</a>
              </div>
              <p>Tests: none</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>	Object.<span class="hljs-function"><span class="hljs-title">isa</span> = <span class="hljs-params">(constructor)</span> -&gt;</span> <span class="hljs-keyword">switch</span>

		<span class="hljs-keyword">when</span> constructor == Number
			<span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> obj <span class="hljs-keyword">instanceof</span> Number <span class="hljs-keyword">or</span> <span class="hljs-keyword">typeof</span> obj == <span class="hljs-string">'number'</span>
	
		<span class="hljs-keyword">when</span> constructor == String
			<span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> obj <span class="hljs-keyword">instanceof</span> String <span class="hljs-keyword">or</span> <span class="hljs-keyword">typeof</span> obj == <span class="hljs-string">'string'</span>
	
		<span class="hljs-keyword">when</span> constructor == Boolean
			<span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> obj <span class="hljs-keyword">instanceof</span> Boolean <span class="hljs-keyword">or</span> <span class="hljs-keyword">typeof</span> obj == <span class="hljs-string">'boolean'</span>
	
		<span class="hljs-keyword">when</span> constructor == Value
			<span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> obj != <span class="hljs-literal">undefined</span>
	
		<span class="hljs-keyword">when</span> constructor.valid?
			<span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> constructor.valid obj
	
		<span class="hljs-keyword">else</span>
			<span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> obj <span class="hljs-keyword">instanceof</span> constructor
			
	<span class="hljs-built_in">window</span>.PreconditionError = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Error</span></span>
	
	<span class="hljs-built_in">window</span>.PostconditionError = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Error</span></span></pre></div></div>
            
        </li>
        
    </ul>
  </div>
</body>
</html>
